package ctrl

import cn.xnatural.app.{Lazier, ServerTpl}
import cn.xnatural.app.Utils.baseDir
import cn.xnatural.http.{Ctrl, HttpContext, Path}

import java.io.File

@Ctrl
class MainCtrl extends ServerTpl {

  lazy val staticDir = app.getAttr("web.staticDir", classOf[String], "src/main/resources/static/")

  @Path(path = Array("index.html", "/"))
  def index(hCtx: HttpContext): File = {
    hCtx.response.cacheControl(10)
    baseDir(staticDir + "index.html")
  }
}
